from django.shortcuts import render_to_response
from django.http import HttpResponse
from datas.models import *
from django.http import HttpResponseRedirect
import datetime

def main(request):
	return render_to_response('main.html')
	
def inform_form(request):

	error = []
	comID = Computer.objects.all()
	#addInform = Inform.objects.all()
	
	if 'symptom' in request.GET or 'comID' in request.GET:
	
		ID = request.GET['comID']
		symptom = request.GET['symptom']
		
		#if not comID:
		#	error.append('Enter comID.')
		if not symptom:
			error.append('Enter symptom.')
		if error:
			return render_to_response('./datas/inform_form.html',{'errors': error, 'comIDs': comID})
		

		com = Computer.objects.get(comID=ID)
		com.status = False
		
		com.save()
		
		#now = datetime.datetime.now()
		#inF = Inform.objects.create(symptom=symptom)
		p = symptom
		p.save()

		
		return render_to_response('./datas/success.html')
				
	else:		

		return render_to_response('./datas/inform_form.html', {'comIDs': comID})
	

	
def inform_Display(request):

	comID = Computer.objects.all()
	
	return render_to_response('./datas/inform_Display.html', {'comIDs': comID})
	
	
	
	
	
